Skip to content

CK Tile Group GEMM gfx1250#576

Merged
aris134 merged 6 commits into
gfx1250from
amartin/ck-group-gemm-gfx1250-clean
May 21, 2026
Merged

CK Tile Group GEMM gfx1250#576
aris134 merged 6 commits into
gfx1250from
amartin/ck-group-gemm-gfx1250-clean

Conversation

@aris134

@aris134 aris134 commented May 6, 2026

Copy link
Copy Markdown
Contributor

Description

Extend the present CK tile grouped GEMM (F16/F8) implementation for compatibility with gfx1250. Replaces 3rdparty/aiter with 3rdparty/rocm-libraries for the gfx1250 changes from CK.

Fixes #16490

Type of change

  • Documentation change (change only to the documentation, either a fix or a new content)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Infra/Build change
  • Code refactoring

Changes

Please list the changes introduced in this PR:

  • Change A
  • Change B

Checklist:

  • I have read and followed the contributing guidelines
  • The functionality is complete
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@aris134 aris134 requested a review from wenchenvincent as a code owner May 6, 2026 17:54
@aris134 aris134 added the ci-level 1 CI test level 1 label May 6, 2026
@aris134 aris134 requested review from ipanfilo and wangye805 as code owners May 6, 2026 17:54
@aris134 aris134 assigned aris134 and unassigned matthiasdiener and aris134 May 6, 2026
@aris134 aris134 requested a review from matthiasdiener May 6, 2026 17:55
@aris134 aris134 changed the title CK Tile Group GEMM GFX1250 CK Tile Group GEMM gfx1250 May 6, 2026
// Currently only support cutlass group gemm on Hopper Arch
if (!(is_hopper && use_cutlass)) {
//if (!(is_hopper && use_cutlass)) {
if (!use_cutlass) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is CUDA path

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted in 752e0d3

using type = TileCfg_256x256x64_WMMA;
};

template <GPUArch Arch>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it need template over reguler if-else or switch-case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template is needed because the arch selection affects CK kernel template instantiation, not just runtime control flow. GPUArch must be a compile-time value so if constexpr can prune unsupported tile/kernel combinations for a given architecture. In this case, it prevents the MFMA configs from being instantiated for gfx1250.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't compile it with gfx1250 arch only but I was still puzzled about this templated dispatch. In line 298, you still rely on runtime detect_gpu_arch() to branch to specific ck_tile_grouped_gemm_fp16_dispatch_arch<arch_id>'s. So I presume all three arches verions will still be instantiated? And I didn't see any compile time guarding?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Before the latest change the runtime switch still referenced all ck_tile_grouped_gemm_fp16_dispatch_arch<...> specializations, so the compiler could still instantiate all arch variants. b55fe29 adds compile-time #if defined(__gfxXXX__) guards around each runtime dispatch case so unsupported arch paths are no longer instantiated.

@aris134 aris134 requested a review from ipanfilo May 11, 2026 13:04
Comment thread transformer_engine/common/gemm/ck_grouped_gemm/ck_grouped_gemm_common.h Outdated
Comment on lines +57 to +63
static constexpr ck_tile::index_t M_Warp_Tile = 16;
static constexpr ck_tile::index_t N_Warp_Tile = 16;
static constexpr ck_tile::index_t K_Warp_Tile = 32;

static constexpr bool kPadM = true;
static constexpr bool kPadN = true;
static constexpr bool kPadK = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the difference btw TileCfg_256x256x64_MFMA and TileCfg_256x256x64_WMMA is inside M, N, K warp tile and kPads?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is not just the warp tile shape or kPads. MFMA and WMMA are different warp-level MMA instruction paths, so they lower through different warp dispatch/pipeline configurations with different tile and padding requirements.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I was comparing those two struct classes TileCfg_256x256x64_MFMA and TileCfg_256x256x64_WMMA. Inside those two defined structs, contents just differ by warp tile and kPads?

using type = TileCfg_256x256x64_WMMA;
};

template <GPUArch Arch>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't compile it with gfx1250 arch only but I was still puzzled about this templated dispatch. In line 298, you still rely on runtime detect_gpu_arch() to branch to specific ck_tile_grouped_gemm_fp16_dispatch_arch<arch_id>'s. So I presume all three arches verions will still be instantiated? And I didn't see any compile time guarding?

COMPILE_OPTIONS "-g0;-dopt=on")
else()
set(CK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/aiter/3rdparty/composable_kernel)
set(CK_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../../3rdparty/rocm_libraries/projects/composablekernel)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Will the whole rocm_libraries too big? Do we have a way to have sparse check out for this ck subdir?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. The full rocm_libraries checkout is fairly large (~8G locally), while projects/composablekernel alone is much smaller (~167M). Yeah, sparse checkout probably makes sense here, but I am wondering if it would be better handled in a separate PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can do it in separate PR

@aris134 aris134 requested a review from wangye805 May 21, 2026 17:02
@aris134 aris134 merged commit a67bbe9 into gfx1250 May 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-level 1 CI test level 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants